package generators;

import java.util.ArrayList;
import java.util.List;

import model.dao.IslandDAO;
import model.entity.Island;
import postgis.PointWrap;
import postgis.util.PostGISUtil;

import com.vividsolutions.jts.io.ParseException;

public class IslandGenerator extends Generator<Island> {
	private List<PointWrap> getPoints() {
		List<PointWrap> points = new ArrayList<PointWrap>();
		PointWrap point = new PointWrap(-38.54955554008484, -3.7233043214519403);
		points.add(point);
		point = new PointWrap(-38.54963734745979, -3.723558593441424);
		points.add(point);
		point = new PointWrap(-38.54954481124878, -3.723585358909731);
		points.add(point);
		point = new PointWrap(-38.54946970939636, -3.7233284103804074);
		points.add(point);
		point = new PointWrap(-38.54955554008484, -3.7233043214519403);
		points.add(point);
		return points;
	}

	protected Island generateOne(int x) {
		Island i = new Island();
		i.setMessages(null);
		i.setName("Ilha" + x);
		// pontos errados, ver como tratar
		try {
			i.setShape(PostGISUtil.getPolygon(getPoints(), null));
		} catch (ParseException e) {
			return null;
		}
		IslandDAO dao = new IslandDAO(Island.class);
		dao.create(i);
		return i;
	}

}
